package com.migration.model.migration.scripts;

import com.migration.model.migration.AbstractMigrationScript;

/**
 * 设备类型表(risk_device_type)迁移脚本
 */
public class A021_RiskDeviceTypeMigrationScript extends AbstractMigrationScript {

    /**
     * 构造函数，初始化迁移配置
     */
    public A021_RiskDeviceTypeMigrationScript() {
        super(
            "risk_device_type",
            "设备类型数据迁移",
            "ra_equip_classify",
            "risk_device_type",
            21
        );
    }

    /**
     * 生成迁移数据的SQL
     *
     * @return 迁移数据的SQL
     */
    @Override
    protected String generateMigrationSql() {
        return "INSERT INTO risk_device_type (\n" +
                "\tid,\n" +
                "  tenant_id,\n" +
                "  parent_id,\n" +
                "  device_type_name,\n" +
                "  create_time,\n" +
                "  update_time,\n" +
                "  create_by,\n" +
                "  update_by,\n" +
                "  is_del\n" +
                ")\n" +
                "SELECT\n" +
                "\tec.id,\n" +
                "  1 as tenant_id,\n" +
                "  ec.parent_id,\n" +
                "  ec.equip_name,\n" +
                "  DATE_FORMAT(ec.create_time, '%Y-%m-%d %H:%i:%s'),\n" +
                "  DATE_FORMAT(ec.update_time, '%Y-%m-%d %H:%i:%s'),\n" +
                "  1,\n" +
                "  1,\n" +
                "  ec.is_del\n" +
                "FROM risk_lunnan_test.ra_equip_classify ec;";
    }

}
